#include "mainwindow_help.h"
#include "ui_mainwindow_help.h"

#include "config.h"

MainWindow_help::MainWindow_help(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow_help)
{
    ui->setupUi(this);

    setFixedSize(size());

    read_file();
    connect(&timer, SIGNAL(timeout()), this, SLOT(put_focus()));
    timer.start(1000/frame_update);
}

MainWindow_help::~MainWindow_help()
{
    delete ui;
}

void MainWindow_help::closeEvent(QCloseEvent* event)
{
    if (!start_game)
        emit close_this();
    start_game = true;
    event->accept();
}

void MainWindow_help::on_pushButton_ok_clicked()
{
    close();
}

void MainWindow_help::put_focus()
{
    ui->pushButton_ok->setFocus();
}

void MainWindow_help::read_file()
{
    QFile help {help_path};
    help.open(QIODevice::ReadOnly);
    QTextStream f_str {&help};
    ui->textBrowser_help->setText(f_str.readAll());
    help.close();
}
